/*class signUpBox
 *
 *since version: 0.5
 *
 *instance of signUpBox
 *
 *
 *
 */
//instance
var signUpBox = null;
//class
function SignUpBox()
{
    this.signUpUsername = new DOMObject("signUpUsername");
    this.signUpPassword = new DOMObject("signUpPassword");
    this.signUpPasswordConfirm = new DOMObject("signUpPasswordConfirm");
    this.signUpRealname = new DOMObject("signUpRealname");
    this.signUpMailbox = new DOMObject("signUpMailbox");
    this.signUpButton = new DOMObject("signUpButton");
    this.popupBox = new PopupBox("signUpBox");
    this
}
SignUpBox.prototype.load = function()
{
    var This = this;
    var xhr = new XMLHttpRequest();
    xhr.open("GET",'signUpBox.ajax',true)
    xhr.onreadystatechange = function()
    {
	if(xhr.readyState ==4)
	{
	    This.popupBox.html(xhr.responseText);
	}
    }
    xhr.send();
}
SignUpBox.prototype.show = function()
{
    this.popupBox.popup();
    if(this.popupBox.innerHTML==this.defaultInnerHTML)
    {
	this.load();
    }
    this.initInteraction();
}
SignUpBox.prototype.showoff = function()
{
    if(this.popupBox.popoff())
	return true;
    else
	return false;
}
SignUpBox.prototype.initInteraction = function()
{
    this.signUpButton.$().onclick = bookLib.summitRegistration;
    this.signUpPasswordConfirm.$().onchange = bookLib.checkPassword;
}
SignUpBox.prototype.checkPassword = function()
{
    if(this.signUpPassword.$().value==this.signUpPasswordConfirm.$().value)
	return true
    return false;
}
SignUpBox.prototype.regist = function()
{
    var username = this.signUpUsername.$().value;
    var password = this.signUpPasswordConfirm.$().value;
    var realname = this.signUpRealname.$().value;
    var mailbox = this.signUpMailbox.$().value;
    if(!logger.regist(username,password,mailbox,realname))
    {
	return false;
    }
    else
    {
	this.showoff();
	logger.login(username,password);
	defaultPage.manageStatus();
	return true;
    }
    
}